package com.zhengtoon.mctoon.conv.dto.mybatis;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 用于实现通用分页信息
 *
 * @author hugy
 * @ClassName: Page
 * @date 2016-05-12
 * Copyright: Copyright (c) 2016
 * Company:ToB中心
 */
public class Page implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1700650176198093475L;
    private int pageNum;//页码
    private int pageSize;//每页行数
    private int startRow;//开始行
    private int endRow;//结束行
    private int dataTotal;//总行数
    private int shelveCount; //上架专题数量
    private int pageCount;//页数
    private Long minuteBefore; // 5分钟之前的时间戳
    private List result;//返回结果
    private Object param;//过滤参数
    private Map<String, String> orderBy;//排序


    public Map<String, String> getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(Map<String, String> orderBy) {
        this.orderBy = orderBy;
    }


    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.startRow = pageNum > 0 ? (pageNum - 1) * pageSize : 0;
        this.endRow = pageNum * pageSize;
    }

    public Object getParam() {
        return param;
    }

    public void setParam(Object param) {
        this.param = param;
    }

    public List getResult() {
        return result;
    }

    public void setResult(List result) {
        this.result = result;
    }

    public int getPageCount() {
        //计算总页数
        if (pageSize > 0) {
            pageCount = dataTotal / pageSize
                    + ((dataTotal % pageSize == 0) ? 0 : 1);
        }
        return pageCount;

    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getEndRow() {
        return endRow;
    }

    public void setEndRow(int endRow) {
        this.endRow = endRow;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

    public int getDataTotal() {
        return dataTotal;
    }

    public void setDataTotal(int dataTotal) {
        this.dataTotal = dataTotal;
    }

    public Long getMinuteBefore() {
        return minuteBefore;
    }

    public void setMinuteBefore(Long minuteBefore) {
        this.minuteBefore = minuteBefore;
    }

    public int getShelveCount() {
        return shelveCount;
    }

    public void setShelveCount(int shelveCount) {
        this.shelveCount = shelveCount;
    }

    @Override
    public String toString() {
        return "Page{" + "pageNum=" + pageNum + ", pageSize=" + pageSize
                + ", startRow=" + startRow + ", endRow=" + endRow + ", dataTotal="
                + dataTotal + ", pageCount=" + pageCount + '}';
    }
}
